<?=view('admin.common.header')?>
<?=view('admin.common.nav')?>
<div class="container">
    <div class="row">
        <div class="panel panel-default">
            <div class="panel-heading">
                公告列表<a href="<?= url("admin/notice/add") ?>" class="btn btn-success btn-xs eveAdd" style="float: right;">发布新公告</a>
            </div>
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th style="width: 150px;">公告标题</th>
                        <th>公告内容</th>
                        <th>#</th>
                    </tr>
                </thead>
                <tbody>
                    <?php if ($notices && count($notices)): ?>
                    <?php foreach ($notices as $val): ?>
                    <tr>
                        <td><?= $val->title ?></td>
                        <td><?= $val->content ?></td>
                        <td><a href="<?=  url("admin/notice/del/{$val->id}")?>" class="btn btn-xs btn-danger eveDel">删除</a></td>
                    </tr>
                    <?php endforeach; ?>
                    <?php endif; ?>
                </tbody>
            </table>
            <?=$notices->render()?>
        </div> 
    </div>
</div>
<script>
    $('.eveDel').click(function(){
        var url = $(this).attr('href');
        layer.confirm('确定要执行删除操作？', {icon:3,title: '删除'}, function(){
            $.get(url, function(data){
               layer.msg(data.info,{icon: 1});
               if (data.status==1) {
                   window.location.reload();
               }
            });
        });
        
        return false;
    });
</script>
<?=view('admin.common.footer')?>